package com.atguigu.userprofile.dao;

import com.atguigu.userprofile.beans.TaskTagRule;
import com.atguigu.userprofile.utils.MySQLUtil;

import java.util.List;

/**
 * @Classname TaskTagRuleDao
 * @Date 2022/10/2 16:41
 * @Created by arun
 */
public class TaskTagRuleDao {

    public static List<TaskTagRule>  selectTaskTagRulesByTaskId(String taskId){
        String sql = " select ttr.id , ttr.tag_id , ttr.task_id, ttr.query_value , " +
                " ttr.sub_tag_id , ti.tag_name as sub_tag_value " +
                " from task_tag_rule ttr  join tag_info ti " +
                " on ttr.sub_tag_id = ti.id " +
                " where ttr.task_id = " + taskId ;
        List<TaskTagRule> taskTagRules = MySQLUtil.selectList(sql, TaskTagRule.class, true);
        return taskTagRules ;
    }

    public static void main(String[] args) {
        List<TaskTagRule> taskTagRules = selectTaskTagRulesByTaskId("1");
        System.out.println(taskTagRules.size());
        taskTagRules.forEach(System.out::println);
    }
}
